package com.blog.utils;

import java.util.Date;
import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

public class TestUtil {
	
	private JdbcTemplate jdbcTemplate;
	
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	public static void sb(){
		System	.out.println(new Date().getTime());
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 10000; i++) {
			sb.append(i+" ");
		}
		System.out.println(new Date().getTime());
		System.out.println(sb);
	}
	
	public static void sf(){
		System.out.println(new Date().getTime());
		StringBuffer sf = new StringBuffer();
		for (int i = 0; i < 10000; i++) {
			sf.append(i+" ");
		}
		System.out.println(new Date().getTime());
		System.out.println(sf);
	}
	
	public static void s(){
		System.out.println(new Date().getTime());
		String s = new String();
		for (int i = 0; i < 10000; i++) {
			s += i+" ";
		}
		System.out.println(new Date().getTime());
		System.out.println(s);
	}
	
	
	public List<?> queryTree(){
		List<?> list = null;
		try {
			list = jdbcTemplate.queryForList("select * from tbl_zTree");
		} catch (DataAccessException e) {
			e.printStackTrace();
		}
		return list;
	}

	public void save() {
		for (int i = 1; i <= 10; i++) {
			for (int j = 1; j <= 10; j++) {
				if((i-1)*10+j==1){
					continue;
				}
				System.out.println((i-1)*10+j+"-"+i);
				String name ="节点"+((i-1)*10+j)+"-"+i;
				String sql = "insert into tbl_zTree values ("+((i-1)*10+j)+","+i+" ,'"+name+"',0,0,1)";
				System.out.println(sql);
				jdbcTemplate.update(sql);
				
			}
		}
		
	}
	
	public static void main(String[] args) {
		String str = "";
	}
}
